import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/

export default defineConfig({
  root: process.cwd(),
  base: '/', // 如果是根目录部署请配置为 /
  // mode: process.env.NODE_ENV,
  publicDir: 'public',
  plugins: [
      vue(),
  ],
  resolve: {
    alias: [],
  },
  server: {
    port: '8090',
    strictPort: false,
    open: false,
    cors: true,
    proxy: {
      // 字符串简写写法
      '/foo': 'http://localhost:4567/foo',
      // 选项写法
      '/api': {
        target: 'http://jsonplaceholder.typicode.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/fct': {
        target: 'https://api2.pushdeer.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/fct/, '')
      },
      // 正则表达式写法
      '^/fallback/.*': {
        target: 'http://jsonplaceholder.typicode.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/fallback/, '')
      },
    },
  },
  build: {
    // outDir: 'xdist',
    assetsDir: 'assets',
    sourcemap: false,
    manifest: false,
    brotliSize: false,
  },
  optimizeDeps: {
    include: [
      "vue",
      "vform3-builds",
      // "vuex",
      // "vue-router",
      // "vant",
      // "axios",
    ],
  },
})

// select cc.areaname,sum(nums1) 光口网关,
// sum(nums2) CM网关,sum(nums3) 小计,
// sum(n2021a) 光口网关2021,sum(n2021b) CM网关2021,
// sum(n2021c) 小计2021
//  from (
// select a.areaname,
// sum(if(locate('光口',a.devname)>0,1,0)*(xiaoshou+zengsong+zuyong+peizhi+huishou+gh_in+zhuxiao_in-gh_out)) nums1,
// sum(if(locate('光口',a.devname)=0,1,0)*(xiaoshou+zengsong+zuyong+peizhi+huishou+gh_in+zhuxiao_in-gh_out)) nums2, 
// sum(xiaoshou+zengsong+zuyong+peizhi+huishou+gh_in+zhuxiao_in-gh_out) nums3,0 n2021a,0 n2021b,0 n2021c
// from bd_b_dev a
// where a.devname like '%网关%'
// and a.devtype='机顶盒'
// group by a.areaname
// union all
// select a.areaname,0,0,0,
// sum(if(locate('光口',a.devname)>0,1,0)*(xiaoshou+zengsong+zuyong+peizhi+huishou+gh_in+zhuxiao_in-gh_out)) nums1,
// sum(if(locate('光口',a.devname)=0,1,0)*(xiaoshou+zengsong+zuyong+peizhi+huishou+gh_in+zhuxiao_in-gh_out)) nums2, 
// sum(xiaoshou+zengsong+zuyong+peizhi+huishou+gh_in+zhuxiao_in-gh_out) nums3 
// from bd_b_dev a
// where a.devname like '%网关%'
// and a.devtype='机顶盒'
// and a.fmonth>202100
// group by a.areaname
// ) cc 
// group by cc.areaname
